package com.ponhu.ea2.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ponhu.ea2.annotations.EnableColumnChangeLog;
import com.ponhu.ea2.enums.InventoryAppraisalEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

@Data
@Accessors(chain = true)
@ApiModel(value = "货品详情查询-数据传输模型 ")
public class PhInventoryDetailVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "货品ID")
    private Long id;

    @ApiModelProperty(value = "货品编码")
    private String inventoryCode;

    @ApiModelProperty(value = "物料ID")
    private String materialId;

    @ApiModelProperty(value = "货品名称")
    private String inventoryName;

    @ApiModelProperty(value = "货品主图")
    private String mainImage;

    @JsonIgnore
    @ApiModelProperty(value = "货品细节图", hidden = true)
    private String detailImage;

    @ApiModelProperty(value = "货品细节图")
    private List<String> detailImages;

    @ApiModelProperty(value = "品牌名称")
    private String brandName;

    @ApiModelProperty(value = "品牌ID")
    private Long brandId;

    @ApiModelProperty(value = "品类ID")
    private Long categoryId;

    @ApiModelProperty(value = "品类名称")
    private String categoryName;

    @ApiModelProperty(value = "货品类型：0-全部，1-主品，2-附件，3-配件，4-赠品")
    private Integer inventoryType;

    @ApiModelProperty(value = "是否二奢：0-全部，1是，2否")
    private Integer isSecondhand;

    @ApiModelProperty(value = "成色字典值")
    private Integer quality;

    @ApiModelProperty(value = "成色")
    private String qualityValue;

    @ApiModelProperty(value = "鉴定师ID")
    private Integer appraiserId;

    @ApiModelProperty(value = "鉴定师")
    private String appraiserName;

    @ApiModelProperty(value = "原产地")
    private String provenance;

    @ApiModelProperty(value = "年份")
    private String year;

    @ApiModelProperty(value = "采购渠道")
    private String sourceChannel;

    @ApiModelProperty(value = "货品来源渠道：字典值")
    private Integer inventoryChannel;

    @ApiModelProperty(value = "货品来源渠道：字典标签名称")
    private String ivtChannelLabel;

    @ApiModelProperty(value = "瑕疵")
    private String flaw;

    @ApiModelProperty(value = "备注")
    private String remarks;

    @ApiModelProperty(value = "中检状态：0-全部，1未中检，2中检已通过，3中检未通过")
    private Integer isDoneCcic;

    @ApiModelProperty(value = "中检状态说明")
    private String isDoneCcicStr;

    @ApiModelProperty(value = "货品相关物料详情")
    private PhMaterialVo phMaterialVo;

    @ApiModelProperty(value = "货品相关商品详情")
    private PhInevntoryGoodsDetailVo goodsInfoForInevntoryVo;

    @ApiModelProperty(value = "货品属性：编辑货品时使用")
    private List<PhPropertyEditVo> phPropertyVos;

    @ApiModelProperty(value = "货品属性：货品详情使用")
    private List<PhPropertyVo> phPropertList;

    @ApiModelProperty(value = "货品附件集合")
    private List<PhInventoryAccessoryVo> annexList;

    @ApiModelProperty(value = "货品配件集合")
    private List<PhInventoryAccessoryVo> accessoryList;

    @ApiModelProperty(value = "是否上传白底图")
    private String baseMap;

    @ApiModelProperty(value = "包小检识图ID")
    private String itemId;

    @ApiModelProperty(value = "包小检识图结果")
    private String bxjAiJson;

    @ApiModelProperty(value = "检测备注")
    private String maintainRemarks;

    @ApiModelProperty(value = "检测结果")
    private String maintainResult;

    public List<String> getDetailImages() {
        if (StringUtils.isNotBlank(detailImage)) {
            return Arrays.asList(detailImage.split("\\|"));
        } else {
            return null;
        }
    }

    public String getIsDoneCcicStr() {
        Optional<String> optional = Arrays.stream(InventoryAppraisalEnum.values())
                .filter(aEnum -> aEnum.getCode().equals(isDoneCcic))
                .map(InventoryAppraisalEnum::getName).findFirst();
        if (optional.isPresent()) return optional.get();
        else return null;
    }

}
